package com.accp.demo.service.finance;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.accp.demo.mapper.finance.PaymentMapper;
import com.accp.demo.pojo.finance.Payment;
import com.accp.demo.pojo.finance.PaymentContent;
import com.accp.demo.pojo.finance.PaymentTakePrepay;

@Service
public class PaymentService {
	
		@Autowired
		private PaymentMapper  iPaymentMapper;
		
		//应付充款单付款充款主详新增
		public void savePayment(Payment pojo){
			iPaymentMapper.savePayment(pojo);
		}
		
		//应付充款单付款充款主详修改
		public void updatePayment(Payment pojo){
			if(pojo.getPaymentContents()!=null && pojo.getPaymentTakePrepays()!=null){
				iPaymentMapper.deletecontent(pojo.getFundBillNo());
				iPaymentMapper.deletetakeprepay(pojo.getFundBillNo());
			}
			
			iPaymentMapper.updatePayment(pojo);
			
			for (PaymentContent contemt : pojo.getPaymentContents()) {
				iPaymentMapper.savecontent(contemt);
			}
			
			for (PaymentTakePrepay prepay : pojo.getPaymentTakePrepays()) {
				iPaymentMapper.savetakeprepay(prepay);
			}
		}
		
		
}
